<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>系统设置</title>
<%@include file="/WEB-INF/jsps/header.jsp"%>
<style type="text/css">
table {
    background-color: #ffffff;
    border-collapse: collapse;
    border: 1px solid #aca899;
}
td {
    background-color: #ffffff;
    padding: 2px;
    text-align: left;
    vertical-align:top;
    border: 1px solid #aca899;
}
</style>
<script type="text/javascript">
function add(){
	$("#dlg").dialog({
		title:"新增属性",
		width:600,
		height:400,
		modal : true,
		closable : true,
		href:"add.at",
		buttons:[
			{
				text:"保存",
				handler:function(){
					saveSetting();
				}
			}    
		]
	});
}

function saveSetting(){
	var form  = $("#form1");
	var valid = form.form("validate");
	if(valid){
		goAjax({
			url:form.attr("action"),
			data:$.serializeObject(form),
			callback:function(json){
				$.messager.alert('提示','保存成功','info',function(){
					//$("#dlg").dialog("close");
					window.location.reload(true);
				});
			}
		});
	}
}

function saveItem(name,des){
	goAjax({
		url:"save.at",
		data:{type:"update",name:name,value:$("textarea[name="+name+"]").val(),description:des},
		callback:function(json){
			$.messager.alert('提示','保存成功','info',function(){
				window.location.reload(true);
			});
		}
	});
}

function delItem(name){
	parent.$.messager.confirm("提示","确定要删除吗？",function(r){
		goAjax({
			url:"del.at",
			data:{name:name},
			callback:function(json){
				$.messager.alert('提示','删除成功','info',function(){
					window.location.reload(true);
				});
			}
		});
	});
}

function clearCache(){
	goAjax({
		url:"clearCache.at",
		callback:function(json){
			$.messager.alert('提示','刷新成功','info');
		}
	});
}

</script>
</head>
<body>

<div class="easyui-panel" title="系统参数设置" style="width:1000px;padding:10px;"
   data-options="iconCls:'icon-save',tools:'#tt'">
<table style="width: 98%" cellpadding="10px" cellspacing="10px">
	<c:forEach items="${list }" var="item">
	<tr>
		<td style="width: 150px">${item.description }</td>
		<td>
		${item.name }
		</td>
		<td>
			<textarea rows="10" cols="20" name="${item.name }" style="width: 98%">${item.value }</textarea>
		</td>
		<td style="width: 120px">
			 <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" style="width:80px" onclick="saveItem('${item.name }','${item.description }')">保  存</a><br/>
			 <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove'" style="width:80px" onclick="delItem('${item.name }')">删   除</a>
		</td>
	</tr>
	</c:forEach>
</table>

 <div id="tt">
    <a href="javascript:void(0)" class="icon-add" onclick="javascript:add()"></a>
    <a href="javascript:void(0)" class="icon-reload" onclick="javascript:clearCache()"></a>
</div>
</div>

<div id="dlg"></div>
</body>
</html>